#include "Subsystem/RoomManager/RoomManagerFunctionLibrary.h"

#include "Subsystem/RoomManager/RoomManagerSubsystem.h"
#include "Subsystem/ItemManager/RoomLightManagerSubsystem.h"

URoomManagerSubsystem* URoomManagerFunctionLibrary::GetRoomManagerSubsystem(const UObject* WorldContextObject)
{
	return GetGameInstanceSubsystem<URoomManagerSubsystem>(WorldContextObject);
}

URoomLightManagerSubsystem* URoomManagerFunctionLibrary::GetRoomLightManagerSubsystem(const UObject* WorldContextObject)
{
	return GetGameInstanceSubsystem<URoomLightManagerSubsystem>(WorldContextObject);
}

FName URoomManagerFunctionLibrary::GetActorRoomName(const UObject* WorldContextObject, AActor* InActor)
{
	if (const UWorld* World = WorldContextObject->GetWorld())
	{
		if (const UGameInstance* GameInstance = World->GetGameInstance())
		{
			if (const URoomManagerSubsystem* RoomManagerSubsystem = GameInstance->GetSubsystem<URoomManagerSubsystem>())
			{
				return RoomManagerSubsystem->GetActorRoomName(InActor);
			}
		}
	}

	return NAME_None;
}

bool URoomManagerFunctionLibrary::IsValidRoomName(const FName& RoomName)
{
	return RoomName != NAME_None && !RoomName.IsNone();
}
